package com.qf.controller;

import com.qf.config.AliyunOssConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 使用配置文件 上传图片到阿里云服务器
 * @author lixu
 */
@RestController
public class OSSController {

    /**
     * 办法1  ：
     */
/*    @Value("${aliyun.oss.endpoint}")
    private String endpoint;*/
/*    @Value("${aliyun.oss.endpoint}")
    private String endpoint;*/
/*    @Value("${aliyun.oss.endpoint}")
    private String endpoint;*/
/*    @Value("${aliyun.oss.endpoint}")
    private String endpoint;*/

    /**
     * 办法2
     */
    @Autowired
    private AliyunOssConfig aliyunOssConfig;

    //办法3
    @Autowired
    private Environment environment;//environment:环境

    /**
     *
     * @return
     */
    @GetMapping("/oss")
    public String oss(){

        String port = environment.getProperty("server.port");
        String redisHost = environment.getProperty("spring.redis.host");
        String endpoint = environment.getProperty("aliyun.oss.endpoint");
        System.out.println("");
        System.out.println("===" + aliyunOssConfig.getEndpoint() + "::" + aliyunOssConfig.getAccessKeyId());

        return "OK";
    }
}
